package cn.lili.modules.serviceimpl;

import cn.lili.common.utils.StringUtils;
import cn.lili.modules.entity.AppShare;
import cn.lili.modules.mapper.AppShareMapper;
import cn.lili.modules.service.AppShareService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @author:xiangqian
 * @date: 2024/3/12 13:57
 */
@Service
public class AppShareServiceImpl extends ServiceImpl<AppShareMapper, AppShare> implements AppShareService {

    /**
     * 根据user_id和gid查询
     *
     * @param userId 用户ID
     * @param gid    视频ID
     */
    @Override
    public AppShare getAppShareBy(String userId, String gid) {
        LambdaQueryWrapper<AppShare> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AppShare::getUser_id, userId);
        queryWrapper.eq(AppShare::getGid, gid);
        queryWrapper.last("limit 1");
        return this.baseMapper.selectOne(queryWrapper);
    }
}
